package com.sky.dto;

import com.sky.entity.SetmealDish;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.validator.constraints.Range;
import org.hibernate.validator.constraints.URL;

import javax.validation.constraints.*;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class SetmealDTO implements Serializable {

    // 新增分组
    public interface Save{}
    // 修改分组
    public interface Update{}


    @Null(groups = Save.class,message = "id必须为null")
    @NotNull(groups = Update.class,message = "id不能为null")
    private Long id;

    //分类id
    @NotNull(groups = {Save.class,Update.class})
    private Long categoryId;

    //套餐名称
    @NotEmpty(groups = {Save.class,Update.class})
    private String name;

    //套餐价格
    @Digits(groups = {Save.class,Update.class},integer = 5,fraction = 2)
    @Range(groups = {Save.class,Update.class},min = 1)
    private BigDecimal price;

    //状态 0:停用 1:启用
    private Integer status;

    //描述信息
    private String description;

    //图片
    @URL(groups = {Save.class,Update.class})
    private String image;

    //套餐菜品关系
    @Size(groups = {Save.class,Update.class},min = 1,max = 20,message = "菜品的个数必须在1和20之间")
    private List<SetmealDish> setmealDishes = new ArrayList<>();

}
